import { requestClient } from '#/api/request';

export namespace SceneApi {
  export interface addedData {
    sceneId: string;
    fileId: string;
    type: string;
  }
}

const getSceneList = (
  userId: string,
  pageSize: number,
  currentPage: number,
  keyword: string,
) =>
  requestClient.get(
    `dsc-systemMS/dsc-scene/getList/${userId}/${pageSize}/${currentPage}?keyword=${keyword}`,
  );

const getGDVSceneConfig = (sceneId: string) =>
  requestClient.get(`/dsc-systemMS/dsc-scene/getSceneConfig/GDV/${sceneId}`);

const deleteScene = (userId: string, sceneId: string) =>
  requestClient.delete(`/dsc-systemMS/dsc-scene/delete/${userId}/${sceneId}`);

const saveScene = (saveSceneParams: any, config: any) =>
  requestClient.put('/dsc-systemMS/dsc-gdv-scene', saveSceneParams, config);

const createDAScene = (createDASceneParams: any) =>
  requestClient.post('/dsc-systemMS/dsc-da-scene', createDASceneParams);

const getDASceneConfig = (sceneId: string) =>
  requestClient.get(`/dsc-systemMS/dsc-scene/getSceneConfig/DAS/${sceneId}`);

const addFile2SceneData = (info: SceneApi.addedData) =>
  requestClient.post('/dsc-systemMS/dsc-da-scene/addData2Scene', info);

// 发布到公共场景
const publishScene = (userId: string, sceneId: string) =>
  requestClient.post('/dsc-systemMS/dsc-scene/publish2Public', {
    userId,
    sceneId,
  });

// 获取公共场景列表
const getPublicSceneList = (
  pageSize: number,
  currentPage: number,
  keyword: string,
) =>
  requestClient.get(
    `/dsc-systemMS/dsc-public-resource/scene/getSceneList/${pageSize}/${currentPage}?keyword=${keyword}`,
  );

// 删除公共场景
const deletePublicScene = (userId: string, sceneId: string) =>
  requestClient.delete(
    `/dsc-systemMS/dsc-public-resource/scene/${userId}/${sceneId}`,
  );

// 引入公共场景
const importScene = (userId: string, sceneId: string) =>
  requestClient.post('/dsc-systemMS/dsc-scene/import', { userId, sceneId });

// 将场景导出为地图
const publishMap = (
  sceneId: string,
  userId: string,
  mapName: string,
  mapStyle: any,
  introduction: string,
) =>
  requestClient.post('/dsc-systemMS/dsc-gdv-scene/publishMap', {
    sceneId,
    userId,
    mapName,
    mapStyle,
    introduction,
  });

export default {
  getSceneList,
  getGDVSceneConfig,
  deleteScene,
  saveScene,
  createDAScene,
  getDASceneConfig,
  addFile2SceneData,
  publishScene,
  getPublicSceneList,
  deletePublicScene,
  importScene,
  publishMap,
};
